package file;

import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;

public class Demo1 {
    public static void main(String[] args) throws IOException {
        File f=new File("e:\\bb\\cc\\aa.txt");
        System.out.println(f.length());
        System.out.println(f.canWrite());
        System.out.println(f.getName());
        System.out.println(f.getTotalSpace());
        System.out.println(f.getParentFile().getName());
        System.out.println(f.getPath());
        System.out.println(f.getCanonicalPath());
        System.out.println("-----------------");
        File[] files=File.listRoots();//列出可用的文件系统根
        for (File file:files){
            System.out.println(file.getPath());
        }
        File[] gf=files[2].listFiles();
        System.out.println("-----------------");
        List<File> fileList=new ArrayList<>();//存放文件夹
        for (File file:gf){
            if (file.isDirectory())
            System.out.println(file.getPath()+"\t"+"<DIR>");
            else
                fileList.add(file);
        }
        for (File file:fileList){
            System.out.println(file.getPath()+"\t"+file.length());
        }
    }
}
